package glmodel;

import java.util.ArrayList;

/**
 * Vertex contains an xyz position, and a list of neighboring triangles. Normals
 * and texture coordinates are stored in the GL_Triangle object, since each face
 * may have different normals and texture coords for the same vertex. The
 * "neighbor" triangle list holds all triangles that contains this vertex. Not
 * to be confused with the GL_Triangle.neighborsP1, GL_Triangle.neighborsP2,
 * etc. that contain only neighbors that should be smoothed into the given
 * triangle. jun 2006: added makeClone()
 */
class GL_Vertex
{
	protected GL_Vector				pos				= new GL_Vector();				// xyz coordinate of vertex
	protected GL_Vector				posS			= new GL_Vector();				// xyz Screen coords of projected vertex
	protected int						ID;											// index into parent objects vertexData vector
	protected ArrayList<GL_Triangle>	neighborTris	= new ArrayList<GL_Triangle>(); // Neighbor triangles of this vertex

	public GL_Vertex()
	{
		pos = new GL_Vector(0f, 0f, 0f);
	}

	protected GL_Vertex(float xpos, float ypos, float zpos)
	{
		pos = new GL_Vector(xpos, ypos, zpos);
	}

	/**
	 * add a neighbor triangle to this vertex
	 */
	void addNeighborTri(GL_Triangle triangle)
	{
		if (!neighborTris.contains(triangle))
		{
			neighborTris.add(triangle);
		}
	}

	/**
	 * clear the neighbor triangle list
	 */
	void resetNeighbors()
	{
		neighborTris.clear();
	}

	

	public String toString()
	{
		return new String("<vertex  x=" + pos.x + " y=" + pos.y + " z=" + pos.z + ">\r\n");
	}

}